import { Equal, Expect } from "@type-challenges/utils";

type CamelCase<S> = S extends `${infer F}-${infer M}${infer L}`
  ? M extends Uppercase<M>
    ? `${F}-${CamelCase<`${M}${L}`>}`
    : `${F}${Uppercase<M>}${CamelCase<L>}`
  : S;

// M匹配第一个匹配到的字母
// type CamelCaseM<S> = S extends `${infer F}-${infer M}${infer L}` ? M : S;
// type M = CamelCaseM<"foo-bar-baz">;

type cases = [
  Expect<Equal<CamelCase<"foo-bar-baz">, "fooBarBaz">>,
  Expect<Equal<CamelCase<"foo-Bar-Baz">, "foo-Bar-Baz">>,
  Expect<Equal<CamelCase<"foo-Bar-baz">, "foo-BarBaz">>,
  Expect<Equal<CamelCase<"foo-bar">, "fooBar">>,
  Expect<Equal<CamelCase<"foo_bar">, "foo_bar">>,
  Expect<Equal<CamelCase<"foo--bar----baz">, "foo-Bar---Baz">>,
  Expect<Equal<CamelCase<"a-b-c">, "aBC">>,
  Expect<Equal<CamelCase<"a-b-c-">, "aBC-">>,
  Expect<Equal<CamelCase<"ABC">, "ABC">>,
  Expect<Equal<CamelCase<"-">, "-">>,
  Expect<Equal<CamelCase<"">, "">>,
  Expect<Equal<CamelCase<"😎">, "😎">>
];
